package com.sicnu.startup.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.sicnu.startup.entity.News;
import com.sicnu.startup.mapper.NewsMapper;
import com.sicnu.startup.service.NewsService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author zr
 * @since 2022-01-08
 */
@Service
public class NewsServiceImpl extends ServiceImpl<NewsMapper, News> implements NewsService {
//    @Cacheable(value = "hotNew", key = "'selectIndexList'")
    @Override
    public List<News> getNews() {
        QueryWrapper<News> queryWrapper = new QueryWrapper<>();
        queryWrapper.orderByDesc("create_time");
        queryWrapper.last("limit 4");
        List<News> news = baseMapper.selectList(queryWrapper);
        return news;
    }
}
